package com.realtyManage.springboot.Service.impl;

import com.realtyManage.springboot.Dao.SysLogRepository;
import com.realtyManage.springboot.Dao.VikiRepository;
import com.realtyManage.springboot.Model.Do.SysLog;
import com.realtyManage.springboot.Model.Do.Viki;
import com.realtyManage.springboot.Model.Vo.SysLogEntity;
import com.realtyManage.springboot.Service.SysLogService;
import com.realtyManage.springboot.Service.VikiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.Predicate;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class VikiServiceImpl implements VikiService {
    @Autowired
    private VikiRepository vikiRepository;

    @Override
    public List<Viki> queryVikiListPool() {
        return vikiRepository.findAll();
    }

    @Override
    public int saveViki(Viki viki) {
        return vikiRepository.save(viki).getId();
    }

    @Override
    public int updateViki(Viki viki) {
        return vikiRepository.update(viki);
    }

    @Override
    public List<Viki> queryVikiList(String title) {
        if (title != null){
            return vikiRepository.queryVikiListE(title);
        }else{
            return vikiRepository.queryVikiList();
        }

    }

    @Override
    public Viki queryVikiById(Integer id) {
        return vikiRepository.queryVikiById(id);
    }
}
